package com.mdd.front.controller;

import com.mdd.common.aop.NotPower;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import com.mdd.front.service.product.IProductSpuFrontService;
import com.mdd.front.validate.product.ProductSpuSearchValidate;
import com.mdd.front.vo.spu.MallSpuVo;
import com.mdd.front.vo.spu.ProductSpuDetailVo;
import com.mdd.front.vo.spu.ProductSpuVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

/**
 * 商品信息
 * {@code @Description}
 * {@code @Author} 幻速
 * {@code @Date} 2023/11/1 18:10
 **/
@RestController
@RequestMapping("api/user/spu")
@Api(tags = "商品")
public class ProductController {
    @Resource
    IProductSpuFrontService iProductFrontService;

    //店铺商品列表
    @NotPower
    @ApiOperation(value = "商品列表")
    @GetMapping("/list")
    public AjaxResult<PageResult<ProductSpuVo>> list(@Validated ProductSpuSearchValidate searchValidate) {
        return AjaxResult.success(iProductFrontService.page(searchValidate));
    }
    //商品详情
    @NotPower
    @GetMapping("/detail")
    @ApiOperation(value = "商品详情")
    public AjaxResult<ProductSpuDetailVo> detail(@Validated @IDMust() @RequestParam("goodsId") Long goodsId) {
        return AjaxResult.success(iProductFrontService.detail(goodsId));
    }
    @NotPower
    @ApiOperation(value = "商城商品列表")
    @GetMapping("/mallList")
    public AjaxResult<PageResult<MallSpuVo>> mallList(@Validated ProductSpuSearchValidate searchValidate) {
        return AjaxResult.success(iProductFrontService.mallPage(searchValidate));
    }
    @NotPower
    @GetMapping("/mallDetail")
    @ApiOperation(value = "商城商品详情")
    public AjaxResult<ProductSpuDetailVo> mallDetail(@Validated @IDMust() @RequestParam("goodsId") Long goodsId) {
        return AjaxResult.success(iProductFrontService.mallDetail(goodsId));
    }


}
